home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog5.arj / TMOUSE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.7 KB  |  75 lines

  1. { tmouse.pas -- Test mouse clicks in windows }
  2.  
  3. program TMouse;
  4.  
  5. uses WinTypes, WinProcs, WObjects;
  6.  
  7. type
  8.  
  9.   MouseApplication = object(TApplication)
  10.     procedure InitMainWindow; virtual;
  11.   end;
  12.  
  13.   PMouseWindow = ^MouseWindow;
  14.   MouseWindow = object(TWindow)
  15.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  16.     procedure WMLButtonDown(var Msg: TMessage);
  17.       virtual wm_First + wm_LButtonDown;
  18.     procedure WMRButtonDown(var Msg: TMessage);
  19.       virtual wm_First + wm_RButtonDown;
  20.   end;
  21.  
  22. { MouseApplication }
  23.  
  24. {- Initialize the application's window }
  25. procedure MouseApplication.InitMainWindow;
  26. begin
  27.   MainWindow := New(PMouseWindow,
  28.     Init(nil, 'Click a Mouse Button Inside This Window'))
  29. end;
  30.  
  31. { MouseWindow }
  32.  
  33. {- Initialize the application's window object }
  34. constructor MouseWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  35. begin
  36.   TWindow.Init(AParent, ATitle);
  37.   with Attr do
  38.   begin
  39.     X := 20; Y := 20; W := 350; H := 150
  40.   end
  41. end;
  42.  
  43. {- Respond to left-button-down mouse clicks }
  44. procedure MouseWindow.WMLButtonDown(var Msg: TMessage);
  45. begin
  46.   MessageBeep(0);
  47.   MessageBox(HWindow, 'Left Button Down', 'Message Box', mb_Ok)
  48. end;
  49.  
  50. {- Respond to right-button-down mouse clicks }
  51. procedure MouseWindow.WMRButtonDown(var Msg: TMessage);
  52. begin
  53.   MessageBeep(0);
  54.   MessageBox(HWindow, 'Right Button Down', 'Message Box', mb_Ok)
  55. end;
  56.  
  57. var
  58.  
  59.   MouseApp: MouseApplication;
  60.  
  61. begin
  62.   MouseApp.Init('TMouse');
  63.   MouseApp.Run;
  64.   MouseApp.Done
  65. end.
  66.  
  67.  
  68. { --------------------------------------------------------------
  69.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  70.   Revision 1.00    Date: 1/11/1991
  71.   ------------------------------------------------------------- }
  72.  
  73.  
  74.  
  75.